import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:hao/page/user/viewModel/RegisterViewModel.dart';
import 'package:hao/page/user/LoginPage.dart';
import 'package:hao/utils/ImageUtil.dart';

import '../../utils/Utils.dart';

class RegisterPage extends StatelessWidget {
  final RegisterViewModel _viewModel = Get.put(RegisterViewModel());

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        decoration: BoxDecoration(gradient: userBgGradient()),
        child: ListView(
          padding: EdgeInsets.only(
              top: MediaQuery.of(context).padding.top,
              bottom: MediaQuery.of(context).padding.bottom),
          children: [
            Container(
              alignment: Alignment.centerRight,
              margin: const EdgeInsets.only(right: 10),
              child: GestureDetector(
                onTap: () {
                  Get.back();
                },
                child: const Icon(Icons.close),
              ),
            ),
            LoginBtnWidget(
              "掌上租管家",
              "你的掌上管家",
            ),
            const SizedBox(
              height: 20,
            ),
            LoginInputWidget(
              zuTextField(
                  controller: _viewModel.phoneController,
                  hintText: '请输入手机号',
                  inputType: TextInputType.phone),
            ),
            const SizedBox(
              height: 20,
            ),
            LoginInputWidget(Row(
              children: [
                Expanded(
                    child: Obx(() => zuTextField(
                        controller: _viewModel.pwdController,
                        hintText: '请输入密码',
                        obscureText: _viewModel.obscure.value,
                        inputType: TextInputType.visiblePassword))),
                GestureDetector(
                  onTap: () {
                    _viewModel.obscure.value = !_viewModel.obscure.value;
                  },
                  child: Obx(() => loadAssetImage(
                      _viewModel.obscure.value ? "login_see" : "login_unsee",
                      width: 25)),
                )
              ],
            )),
            const SizedBox(
              height: 20,
            ),
            LoginInputWidget(
              Row(
                children: [
                  Expanded(
                      child: Obx(() => zuTextField(
                          controller: _viewModel.pwd1Controller,
                          hintText: '请再次输入密码',
                          obscureText: _viewModel.obscure.value,
                          inputType: TextInputType.visiblePassword))),
                  GestureDetector(
                    onTap: () {
                      _viewModel.obscure.value = !_viewModel.obscure.value;
                    },
                    child: Obx(() => loadAssetImage(
                        _viewModel.obscure.value ? "login_see" : "login_unsee",
                        width: 25)),
                  )
                ],
              ),
            ),
            const SizedBox(
              height: 30,
            ),
            LoginBgWidget("注册", () {
              _viewModel.registerClick();
            }),
          ],
        ),
      ),
    );
  }
}
